const Models = require("../../models");

class adminController{
    static async create(ctx){
        //接收客服端
        let req = ctx.request.body;
        if (req.password&&req.number){
            try{
                const data = await Models.admins.create({
                    password: req.password,
                    number: req.number,
                    createAt: new Date(),
                    updateAt: new Date()
                })
                ctx.response.status = 200;
                ctx.body = {
                    code: 200,
                    msg: '创建成功',
                    data
                }
            }catch(err){
                ctx.response.status = 404;
                ctx.body = {
                    code: 200,
                    msg: "参数不全"
                }
            }
        }else{
            ctx.response.status = 416;
            ctx.body = {
                code: 200,
                msg: '参数不齐全'
            }
        }
    }
}

module.exports = adminController;
